log using votechoice.txt, t replace
cd "C:\Users\amel\Documents\Political Effects of Land-Use Regulation" /*change path as needed*/
use votechoice2016, clear

svyset [pweight=postweight], strata(stratum) psu(psu)
gen republican=.
replace republican=0 if votechoice==1
replace republican=0 if votechoice==3
replace republican=0 if votechoice==4
replace republican=0 if votechoice==5
replace republican=1 if votechoice==2
gen age1834=0
replace age1834=1 if V161267x>0 & V161267x<5
gen age3549=0
replace age3549=1 if V161267x>4 & V161267x<8
gen age5064=0
replace age5064=1 if V161267x>7 & V161267x<11
gen age65=0
replace age65=1 if V161267x>10 & !missing(V161267x)
gen southhisp=south*hispanic
gen southwhite=south*white
gen southblack=south*black
gen southasian=south*asian
gen southinc=south*hhinc
gen southcoll=south*college

/*get credible coefficient & standard error estimates on nonsouth college in 2016 presidential vote choice*/
svy: reg republican age1834-age65 south hispanic white black asian hhinc college southhisp southwhite southblack southasian southinc southcoll if V161267x>2

use votechoice2000, clear

svyset psu [pweight=postweight], strata(strat)
gen republican=.
replace republican=0 if votechoice==1
replace republican=0 if votechoice==4
replace republican=1 if votechoice==3
gen age1834=0
replace age1834=1 if age>17 & age<35
gen age3549=0
replace age3549=1 if age>34 & age<50
gen age5064=0
replace age5064=1 if age>49 & age<65
gen age65=0
replace age65=1 if age>64
gen southhisp=south*hispanic
gen southwhite=south*white
gen southblack=south*black
gen southasian=south*asian
gen southinc=south*hhinc
gen southcoll=south*college

/*get credible coefficient & standard error estimates on nonsouth college in 2000 presidential vote choice*/
svy: reg republican age1834-age65 south hispanic white black asian hhinc college southhisp southwhite southblack southasian southinc southcoll if age>24

/*use coefficient & standard error estimates to simulate conversion of nonsouth college between 2000 and 2016*/
set seed 258503213
gen colldiff=-rnormal(-.118371,.0444172)+rnormal(-.1928789,.0281149)
sum colldiff
log close
